<template>
  <el-main>
    <p></p>
    <el-form :inline="true" :model="formInline" class="demo-form-inline">
      <!-- <div style=""></div> -->
      <el-form-item>
        <el-input v-model="formInline.user" placeholder="请输入客户姓名" clearable />
      </el-form-item>
      <el-form-item>
        <el-select v-model="formInline.region" placeholder="请选择状态" clearable>
          <el-option value="已缴费" />
          <el-option value="未缴费" />
        </el-select>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="onSubmit">
          <el-icon><Search /></el-icon>查询
        </el-button>
      </el-form-item>
    </el-form>

    <el-row>
      <el-col :span="2" :offset="22">
        <el-button type="primary" @click="onSubmit"
          ><el-icon><Plus /></el-icon>添加</el-button
        >
      </el-col>
    </el-row>
    <p></p>
    <el-table :data="tableData" style="width: 100%" border>
      <el-table-column label="日期" width="130px">
        <template #default="scope">
          <div style="display: flex; align-items: center">
            <el-icon><timer /></el-icon>
            <span style="margin-left: 10px">{{ scope.row.date }}</span>
          </div>
        </template>
      </el-table-column>
      <el-table-column label="客户姓名" width="80px">
        <template #default="scope">
          <el-tag>{{ scope.row.name }}</el-tag>
        </template>
      </el-table-column>
      <el-table-column label="客户地址" width="260px">
        <template #default="scope">
          <span>{{ scope.row.address }}</span>
        </template>
      </el-table-column>
      <el-table-column label="手机号" width="120px">
        <template #default="scope">
          <span>{{ scope.row.phone }}</span>
        </template>
      </el-table-column>
      <el-table-column label="用水量(m³)" width="80px">
        <template #default="scope">
          <span>{{ scope.row.waterConsumption }}</span>
        </template>
      </el-table-column>
      <el-table-column label="水费(¥)" width="80px">
        <template #default="scope">
          <span>{{ scope.row.waterRate }}</span>
        </template>
      </el-table-column>
      <el-table-column label="用电量(度)" width="80px">
        <template #default="scope">
          <span>{{ scope.row.electricConsumption }}</span>
        </template>
      </el-table-column>
      <el-table-column label="电费(¥)" width="80px">
        <template #default="scope">
          <span>{{ scope.row.electricRate }}</span>
        </template>
      </el-table-column>
      <el-table-column label="总费用(¥)" width="80px">
        <template #default="scope">
          <span>{{ scope.row.totalRate }}</span>
        </template>
      </el-table-column>
      <el-table-column fixed="right" label="操作" min-width="120">
        <template #default="scope">
          <el-button
            type="primary"
            :icon="Edit"
            size="small"
            @click="handleEdit(scope.$index, scope.row)"
          />

          <el-button
            size="small"
            type="danger"
            :icon="Delete"
            @click="handleDelete(scope.$index, scope.row)"
          >
          </el-button>
        </template>
      </el-table-column>

      <el-table-column label="缴费状态" width="100%">
        <template #default="scope">
          <el-tag :type="scope.row.state === '已缴费' ? 'success' : 'danger'">
            {{ scope.row.state }}
          </el-tag>
        </template>
      </el-table-column>
    </el-table>
    <p></p>
    <el-pagination background layout="prev, pager, next" :total="1000" />
  </el-main>
</template>

<script lang="ts" setup>
import { reactive } from "vue";
import { Phone, Timer } from "@element-plus/icons-vue";
import { ref } from "vue";
import { Delete, Edit, Search, Upload, Plus } from "@element-plus/icons-vue";
import { Document, Menu as IconMenu, Location, Setting } from "@element-plus/icons-vue";
const handleOpen = (key: string, keyPath: string[]) => {
  console.log(key, keyPath);
};
const handleClose = (key: string, keyPath: string[]) => {
  console.log(key, keyPath);
};
const activeIndex = ref("1");
const activeIndex2 = ref("1");
const handleSelect = (key: string, keyPath: string[]) => {
  console.log(key, keyPath);
};
interface User {
  date: string;
  name: string;
  address: string;
  phone: string;
  waterConsumption: string;
  waterRate: string;
  electricConsumption: string;
  electricRate: string;
  totalRate: string;
  state: string;
}

const handleEdit = (index: number, row: User) => {
  console.log(index, row);
};
const handleDelete = (index: number, row: User) => {
  console.log(index, row);
};

const tableData: User[] = [
  {
    date: "2016-05-03",
    name: "Tom",
    address: "No. 189, Grove St, Los Angeles",
    phone: "123456789",
    waterConsumption: "123",
    waterRate: "123",
    electricConsumption: "123",
    electricRate: "123",
    totalRate: "123",
    state: "已缴费",
  },
  {
    date: "2016-05-02",
    name: "Tom",
    address: "No. 189, Grove St, Los Angeles",
    phone: "123456789",
    waterConsumption: "123",
    waterRate: "123",
    electricConsumption: "123",
    electricRate: "123",
    totalRate: "123",
    state: "未缴费",
  },
  {
    date: "2016-05-04",
    name: "Tom",
    address: "No. 189, Grove St, Los Angeles",
    phone: "123456789",
    waterConsumption: "123",
    waterRate: "123",
    electricConsumption: "123",
    electricRate: "123",
    totalRate: "123",
    state: "未缴费",
  },
  {
    date: "2016-05-01",
    name: "Tom",
    address: "No. 189, Grove St, Los Angeles",
    phone: "123456789",
    waterConsumption: "123",
    waterRate: "123",
    electricConsumption: "123",
    electricRate: "123",
    totalRate: "123",
    state: "未缴费",
  },
];
const formInline = reactive({
  user: "",
  region: "",
  date: "",
});

const onSubmit = () => {
  console.log("submit!");
};
</script>

<style>
.demo-form-inline .el-input {
  --el-input-width: 220px;
}

.demo-form-inline .el-select {
  --el-select-width: 220px;
}
</style>
